package com.reverie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.reverie.entity.GoodsGallery;
import com.reverie.mapper.GoodsGalleryMapper;
import com.reverie.service.IGoodsGalleryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Rui.Zhou
 * @since 2024-02-03
 */
@Service
public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, GoodsGallery> implements IGoodsGalleryService {

    @Override
    public List<GoodsGallery> listByGoodIds(Collection<Integer> goodsIds) {
        QueryWrapper<GoodsGallery> wrapper = new QueryWrapper<>();
        wrapper.lambda().in(GoodsGallery::getGoodsId,goodsIds);
        wrapper.lambda().eq(GoodsGallery::getImgType,3);
        wrapper.lambda().orderByAsc(GoodsGallery::getOrderSort);
        return list(wrapper);
    }

    @Override
    public boolean removeByGoodId(Integer goodsId) {
        QueryWrapper<GoodsGallery> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(GoodsGallery::getGoodsId,goodsId);
        return remove(wrapper);
    }
}
